//
//  StationeryViewController.m
//  Quartz2DDemo
//
//  Created by abc on 2019/4/27.
//  Copyright © 2019年 汪保锋. All rights reserved.
//

#import "StationeryViewController.h"

@interface StationeryViewController ()

@end

@implementation StationeryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 1.生成一张以后用于平铺的小图片
    CGSize size = CGSizeMake(self.view.frame.size.width, 35);
    UIGraphicsBeginImageContextWithOptions(size , NO, 0);
   // 2.画矩形
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGFloat height = 35;
    CGContextAddRect(ctx, CGRectMake(0, 0, self.view.frame.size.width, height));
    [[UIColor whiteColor] set];
    CGContextFillPath(ctx);
    
    // 3.画线条
    CGFloat lineWidth = 2;
    CGFloat lineY = height - lineWidth;
    CGFloat lineX = 0;
    CGContextMoveToPoint(ctx, lineX, lineY);
    CGContextAddLineToPoint(ctx, self.view.frame.size.width, lineY);
    [[UIColor brownColor] set];
    CGContextStrokePath(ctx);
    
    UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
    UIColor *color=[UIColor colorWithPatternImage:image];
    self.view.backgroundColor=color;
    
}



@end
